﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Gp.AI;
using Gp.Scripts.Core;
using QFramework;
using UnityEngine;
using Sprite = UnityEngine.Sprite;

namespace Gp.Scripts.GUI {
    [AutoLoad()]
    public class GridBattleGUISystem : BaseGameSystem {
        private readonly List<BattleIndicatorBase> _controllers = new();
        protected override void OnInit() { }

        // public OptionWindowController OptionWindowController;
        //
        // public ClickConformIndicator ClickConformIndicator;
        //
        // public ReactionWindowController ReactionWindowController;

        public FeedBackPlayer FeedBackPlayer;
        


        public IEnumerator OptionWindow(IEnumerable<OptionItem> args) {
            // if (OptionWindowController != null)
                // yield return OptionWindowController.GetOption(args);
            yield break;
        }


        public IEnumerator ReactionSelectWindow<T>(List<BaseReactionEntity> reactionEventWrappers, T args)
            where T : ReactionArgs {
            // if (ReactionWindowController != null)
                // yield return ReactionWindowController.ResolveReactionSelection(reactionEventWrappers, args);
            yield break;
        }


        public void ConformClick(Action onClick, Action onCancel) {
            // if (ClickConformIndicator)
            //     ClickConformIndicator.Show(onClick, onCancel);
        }


        public void ClearConformClick() {
            // if (ClickConformIndicator)
                // ClickConformIndicator.Clear();
        }
        
        
        


        public void PlayFloatingText(BaseUnit unit, string text) {
            FeedBackPlayer.PlayFloatingText(unit, text);
        }

        public void PlayFloatingText(BaseUnit unit, string text, Color color) {
            FeedBackPlayer.PlayFloatingText(unit, text, color);
        }


        public void ShowAIAction(AIActionArgs args) {
            this.SendEvent(args);
        }


        // public void RegisterUIController(BattleIndicatorBase controller) {
        //     if (_controllers.Any(x => x && x.GetType() == controller.GetType())) return;
        //     _controllers.Add(controller);
        // }

        // public T GetIndicator<T>() where T : BattleIndicatorBase {
        //     return _controllers.FirstOrDefault(x => x is T) as T;
        // }
    }

    public class ReactionRenderInfo {
        // public BaseUnit Reactor;
        public Sprite Icon;
        public string Title;
    }


    // public static class FT_Const {
    //     public static readonly string FallApart = "崩解";
    //     public static readonly string DefencePoint = "防御点";
    //     public static readonly string AtkPoint = "进攻点";
    // }
}